package com.gupaoedu.design.observer.review;

/**
 * <p></p>
 *
 * @author Andy
 * @date 2018/4/23.
 */
public enum MouseType {
    ON_CLICK(1,"click"),
    ON_DOUBLE_CLICK(2,"doubleClick"),
    ON_UP(3,"up"),
    ON_DOWN(4,"down"),
    ON_WHEEL(5,"wheel"),
    ON_MOVE(6,"move"),
    ON_OVER(7,"over");

    private int id;
    private String name;

    MouseType(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static MouseType findById(int id) {
        for(MouseType type : MouseType.values()) {
            if (type.id == id) {
                return type;
            }
        }
        return null;
    }

    public static MouseType findByName(String name) {
        for(MouseType type : MouseType.values()) {
            if (type.name.equals(name)) {
                return type;
            }
        }
        return null;
    }

    public static int getId(String name) {
        for(MouseType type : MouseType.values()) {
            if (type.name.equals(name)) {
                return type.id;
            }
        }
        return 0;
    }

    public static String getName(int id) {
        for(MouseType type : MouseType.values()) {
            if (type.id == id) {
                return type.name;
            }
        }
        return "";
    }
}
